-
Notifications
You must be signed in to change notification settings - Fork 545
Support value-of<BackedEnum>
#1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
this part of the initial issue
sounds like a missing rule-check somewhere... I think this can be fixed in a separate PR (which I can work on after this)? |
|
(sorry for trial and error.. have no php 8.1 setup yet locally) build error is unrelated |
ondrejmirtes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a case to NodeScopeResolverTest that tests what value-of resolves to inside a method body.
|
About this:
Yeah, let's discuss this separately in another PR. The issue here is that phpstan-src/src/PhpDoc/TypeNodeResolver.php Line 460 in 14cb258
|
1ca0150 to
90851b1
Compare
ddd20b4 to
95d480b
Compare
|
Please add NodeScopeResolverTest case to verify it works as expected. |
d1ab145 to
2a920cf
Compare
done |
ondrejmirtes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously the implementation in TypeNodeResolver needs to change. Please iterate over ClassReflection::getEnumCases() to get to actual scalar values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require is not needed here, make sure to run composer dump locally first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked it locally.. the tests do not work without this require line.
even if I run composer dump beforehand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh.. I need to /my/php8.1 composer dump and then it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't good enough, right? Should be 'The Netherlands'|'United States' really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also why that bug isn't report in CallMethodsRuleTest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed it. good catch.
0f82164 to
d9bed9f
Compare
768c2a3 to
2759d26
Compare
| function doFooArray() { | ||
| $this->hello(CountryNo::NL); | ||
|
|
||
| // 'abc' does not match value-of<Country> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as expected, we now see errors here.
|
Thank you. |
as requested in phpstan/phpstan#6841 (comment)
closes phpstan/phpstan#6775